<template>
    <div style="width:100%;height:100%;overflow:hidden auto">
        <weui-cell :list="cell_0_list">
        </weui-cell>
    </div>
</template>
<script>
import WeuiCell from '../vue2componentSet/src/components/WeuiCell'
import global from '../lib/global'
import axios from 'axios'

export default {
    components: {
        WeuiCell
    },
    data() {
        return {
            promotees: []
        }
    },
    mounted() {
        this.$store.commit('set_title', '分享佣金明细')

        if (!this.$store.state.customer) {
            this.$router.goback()
            return
        }

        this.getPromotee()
    },
    methods: {
        getPromotee() {
            axios.post(global.server + 'getPromotee.do', {}).then(result => {
                var obj = result.data
                for (var i = 0; i < obj.length; ++i) {
                    for (var j = i + 1; j < obj.length; ++j) {
                        if (obj[i].returnPromoterMoney < obj[j].returnPromoterMoney ||
                            (obj[i].returnPromoterMoney == obj[j].returnPromoterMoney && obj[i].willReturnPromoterMoney < obj[j].willReturnPromoterMoney)
                        ) {
                            var tmp = obj[i]
                            obj[i] = obj[j]
                            obj[j] = tmp
                        }
                    }
                }
                this.promotees = obj
            })
        }
    },
    computed: {
        cell_0_list() {
            var result = []
            this.promotees.forEach(item => {
                result.push({
                    value: item.phone,
                    desc: '已返' + item.returnPromoterMoney + '(待返' + '' + item.willReturnPromoterMoney + ')',
                })
            })
            return result
        }
    }
}
</script>